package model

import (
	"github.com/lib/pq"
	"manager/model/entity"
)

// LoseCreateRequest 创建现场数据
type LoseCreateRequest struct {
	EbikeId int64 `json:"ebike_id"`

	UserId int64 `json:"user_id"`

	Addr string `json:"addr"`

	LoseTime int64 `json:"lose_time"`

	Status int `json:"status"`

	LockStatus int `json:"lock_status"`

	Result string `json:"result"`

	SolverId int64 `json:"solver_id"`

	Desc string `json:"desc"`

	LoseType int `json:"lose_type"`

	EbikeName   string `json:"ebike_name"`
	BatteryNo   string `json:"battery_no"`
	EbikeImage  string `json:"ebike_image"`
	EbikeTypeId int64  `json:"ebike_type_id"`

	UpdatedAt int64 `json:"updated_at"`
}

// LoseUpdateRequest 更新现场数据
type LoseUpdateRequest struct {
	Id int64 `json:"id"`

	EbikeId *int64 `json:"ebike_id"`

	UserId *int64 `json:"user_id"`

	Addr *string `json:"addr"`

	LoseTime *int64 `json:"lose_time"`

	Status *int `json:"status"`

	LockStatus *int `json:"lock_status"`

	Result *string `json:"result"`

	SolverId *int64 `json:"solver_id"`

	Desc *string `json:"desc"`

	LoseType *int `json:"lose_type"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt *int64 `json:"updated_at"`
}

// LoseListRequest 列表现场数据
type LoseListRequest struct {
	Index int `json:"index"`
	Size  int `json:"size"`

	Id int64 `json:"id"`

	EbikeId *int64 `json:"ebike_id"`

	UserId *int64 `json:"user_id"`

	Addr *string `json:"addr"`

	LoseTime *int64 `json:"lose_time"`

	Status *int `json:"status"`

	LockStatus *int `json:"lock_status"`

	Result *string `json:"result"`

	SolverId *int64 `json:"solver_id"`

	Desc *string `json:"desc"`

	UpdatedAt *int64 `json:"updated_at"`

	LoseType *int `json:"lose_type"`

	SearchTime *pq.Int64Array `json:"search_time"`

	TimeZone []int64 `json:"time_zone"`

	EbikeTypeId *int64 `json:"ebike_type_id"`
}

// LoseListResponse 列表回包数据
type LoseListResponse struct {
	Total int         `json:"total"`
	List  []*LoseInfo `json:"list"`
}

// LoseInfoRequest 列表现场数据
type LoseInfoRequest struct {
	Id int64 `json:"id"`

	EbikeId *int64 `json:"ebike_id"`

	UserId *int64 `json:"user_id"`

	Addr *string `json:"addr"`

	LoseTime *int64 `json:"lose_time"`

	Status *int `json:"status"`

	LockStatus *int `json:"lock_status"`

	Result *string `json:"result"`

	SolverId *int64 `json:"solver_id"`

	Desc *string `json:"desc"`

	UpdatedAt *int64 `json:"updated_at"`
}

// LoseInfo 详细数据
type LoseInfo struct {
	Id int64 `json:"id"`

	EbikeId int64 `json:"ebike_id"`

	UserId int64 `json:"user_id"`

	Addr string `json:"addr"`

	LoseTime int64 `json:"lose_time"`

	Status int `json:"status"`

	LockStatus int `json:"lock_status"`

	Result string `json:"result"`

	SolverId int64 `json:"solver_id"`

	LoseType int `json:"lose_type"`

	EbikeName string `json:"ebike_name"`
	BatteryNo string `json:"battery_no"`

	EbikeImage string `json:"ebike_image"`

	EbikeTypeId int64 `json:"ebike_type_id"`

	Desc string `json:"desc"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt int64 `json:"updated_at"`
}

// LoseDeleteRequest 删除现场数据
type LoseDeleteRequest struct {
	Id int64 `json:"id"`
}

// LoseUnlockReq 解锁
type LoseUnlockReq struct {
	EbikeId int64 `json:"ebike_id"`
}

// LosesEntityToDto entity数据转换
func LosesEntityToDto(loses []*entity.Lose) []*LoseInfo {
	out := make([]*LoseInfo, 0, len(loses))
	for _, c := range loses {
		out = append(out, LoseEntityToDto(c))
	}
	return out
}

// LoseEntityToDto entity数据转换
func LoseEntityToDto(e *entity.Lose) *LoseInfo {
	return &LoseInfo{

		Id: e.Id,

		EbikeId: e.EbikeId,

		UserId: e.UserId,

		Addr: e.Addr,

		LoseTime: e.LoseTime,

		Status: e.Status,

		LockStatus: e.LockStatus,

		Result: e.Result,

		SolverId: e.SolverId,

		Desc: e.Desc,

		LoseType:    e.LoseType,
		EbikeName:   e.EbikeName,
		EbikeImage:  e.EbikeImage,
		BatteryNo:   e.BatteryNo,
		EbikeTypeId: e.EbikeTypeId,
		CreatedAt:   e.CreatedAt,

		UpdatedAt: e.UpdatedAt,
	}
}
